package routers

import (
	"github.com/gin-gonic/gin"
	"news-talk/handlers"
)

func Middle(c *gin.Context) {
	c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
	c.Next()
}
func Init() *gin.Engine {
	r := gin.Default()
	r.Use(Middle)
	r.POST("/news/add", handlers.NewsAdd)
	r.GET("/news/list", handlers.NewsList)
	r.GET("news/detail", handlers.NewsDetail)
	r.POST("news/comment", handlers.Comment)
	r.Run(":8081")
	return r
}
